import {BaseDataObject} from "../dataModel/baseDataObject.js";

export class BaseController {
    _view = null;
    _model = null;
    _pubsub = null;

    constructor(view, model, pubsub) {
        this.view = view;
        this.model = model;
        this.pubsub = pubsub;

        document.querySelector('#btn1').addEventListener('click', (e) => {

            this.model.addTodo(new BaseDataObject({id: 456, name: '张三'}))
            // console.log(this.model.todos);
            // this.pubsub.pubsub('test', this.model.todos);
        });

        document.querySelector('#btn2').addEventListener('click', (e) => {

            this.model.deleteTodo(456);
            // console.log(this.model.todos);
            // this.pubsub.pubsub('test', this.model.todos);
        });

    }

    get view() {
        return this._view;
    }

    set view(value) {
        this._view = value;
    }

    get model() {
        return this._model;
    }

    set model(value) {
        this._model = value;
    }

    get pubsub() {
        return this._pubsub;
    }

    set pubsub(value) {
        this._pubsub = value;
    }
}